<?php
/**
 * Framework.php is the core of WP Framework which defines the main class
 *
 * @package WP_Framework
 */

/**
 * class WPFramework - Main class loads all includes, adds/removes filters.
 * 
 * @since - 0.1
 */
class WPFramework {
	
	/**
	 * init() - Initialisation method which calls all other methods in turn.
	 *
	 * @since - 0.1
	 */
	function init() {
		$framework = new WPFramework;
		
		$framework->load_enviroment();
		$framework->core_functionality();
		$framework->get_extentions();
		$framework->default_behavior();
		$framework->ready();
	}
	
	/**
	 * load_enviroment() - defines WP Framework directory constants
	 *
	 * @since - 0.2.3
	 */
	function load_enviroment() {
		define( 'THEMEASSETS', TEMPLATEPATH . '/assets' ); // Shortcut to point to the /assets/ dir
		define( 'THEMEASSETS_URI', get_bloginfo( 'template_url' ) . '/assets' ); // Shortcut to point to the /assets/ URI
		define( 'THEMELIB', TEMPLATEPATH . '/library' ); // Shortcut to point to the /library/ dir
		define( 'FRMWRKCORE', THEMELIB . '/core' ); // Shortcut to point to the /core/ dir
		define( 'FRMWRKMORE', THEMELIB . '/extensions' ); // Shortcut to point to the /extensions/ dir

		// URI Path to default theme asset folders
		define( 'THEMECSS', THEMEASSETS_URI . '/css' );
		define( 'THEMEIMG', THEMEASSETS_URI . '/images' );
		define( 'THEMEJS', THEMEASSETS_URI . '/js' );
	}
	
	/**
	 * core_functionality() - includes all the core functions for WP Framework
	 *
	 * @since - 0.2.3
	 */
	function core_functionality() {
		require_once( FRMWRKCORE . '/framework-hook-system.php' ); // load the WP Framework Hook System
		require_once( FRMWRKCORE . '/general-functions.php' ); // load Framework functions
		require_once( FRMWRKCORE . '/helper-functions.php' ); // load Framework helper functions
	}
	
	/**
	 * get_extentions() - includes all extentions if they exist
	 *
	 * @since - 0.2.3
	 */
	function get_extentions() {
		include_all( FRMWRKMORE . '/' );
	}
	
	/**
	 * default_behavior() - connects WP Framework default behavior to their respective action
	 *
	 * @since - 0.2.3
	 */
	function default_behavior() {
		add_filter( 'the_generator', 'remove_generator_link', 1 ); // remove_generator_link() - Removes generator link - Credits: (http://www.plaintxt.org)
		add_filter( 'post_gallery', 'post_gallery_filter' ); // stops [gallery] styles from being added to the page. making html invalid
		add_action( 'init', 'load_js' ); // load_jquery() - loads screen.js + jQuery
	}
	
	/**
	 * ready() - includes user's theme.php if it exists, calls the framework_init action, includes all pluggable functions and registers widgets
	 *
	 * @since - 0.2.3
	 */
	function ready() {
		if ( file_exists( THEMEASSETS . '/custom-functions.php' ) ) include_once( THEMEASSETS . '/custom-functions.php' ); // include custom-functions.php if that file exist
		do_action( 'framework_init' ); // Available action: framework_init
		
		require_once( FRMWRKCORE . '/pluggable.php' ); // Loads all pluggable functions after theme.php
		register_widgets();
	}
} // end of WPFramework;
?>